home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12032 < prev    next >
Encoding:
Text File  |  1996-08-05  |  962 b   |  26 lines

  1. Newsgroups: comp.lang.c
  2. Path: new-news.sprintlink.net!news1!ind-004-236-163
  3. From: dlmiller@iquest.net (Doug Miller)
  4. Subject: Re: Float to String
  5. X-Nntp-Posting-Host: ind-004-236-163.iquest.net
  6. Message-ID: <DozDv5.69F@iquest.net>
  7. Sender: news@iquest.net (News Admin)
  8. Organization: IQuest Network Services
  9. X-Newsreader: News Xpress Version 1.0 Beta #2.1
  10. References: <4is29s$h1a@dfw-ixnews6.ix.netcom.com> <4j0m8a$1mem@darkwing.cadvision.com>
  11. Date: Thu, 28 Mar 1996 14:09:05 GMT
  12.  
  13. douglasd@cadvision.com (Doran Douglas) wrote:
  14. >scoshe@ix.netcom.com(Christopher Scott Shelton ) wrote:
  15. >
  16. >>Is it possible to convert a float to a string?  like the itoa function.
  17. >try strcpy 'ing the float to a string array
  18. >eg strcpy(string, float_variable_name);
  19. >
  20. >
  21. >
  22. Perhaps you should have tried that yourself... :)  strcpy requires string arguments; your code
  23. won't even compile, let alone execute.  The proper way to do this is with sprintf, e.g.
  24.     sprintf (string, "%f", flt);
  25.  
  26.